Skip to content

feat(tools): verify the CLIs kit says it manages — version, provenance, currency - #504

Merged
sandstream merged 2 commits into
mainfrom
feat/500-tool-verification
Aug 20, 2026
Merged

sandstream merged 2 commits into
mainfrom
feat/500-tool-verification

Conversation

@sandstream

Copy link
Copy Markdown
Owner

Closes #500 (requirements 1–4 and 6; 5 is scoped out below).

The three defects, and what each one now does

1. latest was compared against nothing.

// before — src/check-tools.ts
if (required === "latest") return true;

so ✓ vercel 53.1.1 (need latest) printed while the registry said 59.1.4. Now latest means current, and the tools table says which installer owns the binary and how far behind it is:

✓ node                              22.23.2  (need 22)      [mise]
− pnpm                              10.32.1  (need latest)   [kit-shim]  currency unchecked: kit PATH shim — resolve what it delegates to before asking for a latest version
! aqua:aquasecurity/trivy           0.72.0   (need latest)   [mise]      0.72.0 → 0.74.0 available
! aqua:trufflesecurity/trufflehog   3.95.9   (need latest)   [mise]      3.95.9 → 3.97.0 available

A pin of any / present / * asserts presence only — the honest name for what latest used to do, for repos that mean it.

2. cli-lock.json recorded a provenance it never measured, and the check called it in sync.

Both writers did the same thing — tools[name] = { version, source: "mise" } — recording the declared string as the version and hardcoding the installer. The lock check compared names only. Now the version is the resolved one, the source is classified from the resolved path, sourceDetail carries installers the lock's four-value vocabulary cannot name (brew, system, cargo, kit-shim), and a contradiction fails the row:

✗ cli-lock.json   1 tool(s) with wrong recorded provenance — provenance drift:
  vercel: lock says mise, but /opt/homebrew/bin/vercel comes from brew (re-run `kit fix` to re-record)

3. Undeclared CLIs were invisible. New kit tools list [--latest] [--json] inventories the declared [tools] plus the tools an agent actually decides from — gh, op, jq, mise, docker, gcloud, kubectl, supabase, stripe, psql, git, node, npm, python3, vercel, convex. Not "everything on PATH": an inventory nobody reads is the same failure one level up.

Measured on the reporting machine, first run: trivy 0.72.0 → 0.74.0, trufflehog 3.95.9 → 3.97.0, gh 2.96.0 → 2.97.0, mise 2026.6.11 → 2026.8.9, npm 10.9.8 → 12.0.2, op 2.34.0 → 2.39.0. vercel reads ✓ 59.1.4 — it was upgraded between the report and this branch, which is why the drift class is demonstrated on the six above instead.

Requirement 3 and 6 are the load-bearing parts

An unrunnable check reports why, and never passes. Four distinct outcomes, each with its own reason string: air-gap (no call made), an installer with no registry kit can query (system, cargo, go), a kit PATH shim (the shim delegates — asking about it would answer about the wrong thing), and a lookup that timed out or returned nothing parseable.

The gate does not call registries. kit check uses a cache-only reader: it reports drift the cache already knows and otherwise says so —

− aqua:aquasecurity/trivy  0.72.0  (need latest)  [mise]  currency unchecked: not looked up yet — run `kit tools list --latest` (this gate does not call registries)

kit tools list --latest is what fills the cache (~/.kit/tool-latest.json, TTL via KIT_TOOL_LATEST_TTL_H, default 24h). Cold 12s, warm 4s, and a failed lookup is deliberately not cached — a flaky network must not become a day-long policy.

Two defects found while building it

Tests

  • tool-provenance.test.ts (12) — every installer classified from the real paths on the reporting machine; shim vs installs-path; ordering regressions (kit shim and mise both live under $HOME, Homebrew is reached through /opt/homebrew/bin symlinks); win32 case-insensitivity; and provenanceMismatch catching the exact mise-for-brew case while never alarming on a shim or an unclassifiable path.
  • tool-latest.test.ts (16) — cache hit makes no subprocess; TTL expiry re-asks; air-gap and cache-only each report their own reason; unsupported installers name themselves; a failed lookup is not cached; brew's JSON is parsed rather than the first number in its chatter; and compareVersions numerically (53.1.1 < 59.1.4, 9.0.0 < 10.0.0).
  • tool-inventory.test.ts (10) — probeName across backends, toLockSource mapping everything unnameable to manual instead of guessing mise, and the compiled CLI asserting that every listed tool has a measured source and that nothing claims mise for a path outside mise.

Scoped out, deliberately

  • Requirement 5 (an upgrade path per installer: brew upgrade vs mise upgrade vs npm -g) — that is a mutating command with its own consent and read-only-surface questions, and it belongs with kit upgrade's existing machinery rather than bolted to a reporting change.
  • Resolving through a kit PATH shim to the underlying installer. Reported as unsupported with the reason instead of guessed.

Verification

  • npm test: 4388 tests, 0 fail, 0 skipped (macOS, non-root)
  • kit self-audit: 16 rules, 0 fail, 0 warn · eslint src: 0 errors · prettier --check "src/**/*.ts" clean
  • kit check exercised warm and cold; kit tools list and --latest exercised against real brew/mise/npm

🤖 Generated with Claude Code

…e, currency

Three defects, one root: nothing resolved a declared tool to an actual version,
an actual installer, or a known-latest, and the output made an unverified pass
indistinguishable from a verified pin (#500).

1. `latest` was compared against nothing — `versionSatisfies` returned true for
   it before looking, so `✓ vercel 53.1.1 (need latest)` printed while the
   registry had 59.1.4. `latest` now means CURRENT: the newest version the tool's
   own installer would give, with drift shown as `! 0.72.0 → 0.74.0 available`.
   A pin of any/present/* asserts presence only, and says so.

2. cli-lock.json recorded a provenance it never measured. Both writers did
   `tools[name] = { version, source: "mise" }` — the declared string as the
   version, the installer hardcoded — so an entry said mise for a binary in
   /opt/homebrew/bin, and the check compared names only and called it in sync.
   Now the version is resolved, the source is classified from the path,
   sourceDetail carries installers the lock's four-value vocabulary cannot name,
   and a contradiction fails the row.

3. Undeclared CLIs were invisible. `kit tools list [--latest] [--json]`
   inventories the declared [tools] plus the ones an agent decides from (gh, op,
   jq, mise, docker, gcloud, kubectl, supabase, stripe, psql, …).

The two load-bearing rules, both from kit's own no-false-green stance:

- a lookup that cannot run reports WHY and never passes — air-gap, an installer
  with no registry kit can query, a kit PATH shim (it delegates), a timeout;
- the gate does not call registries. `kit check` reads the cache only and says
  "not looked up yet — run `kit tools list --latest`" when it is cold, so the
  check never becomes slow or network-dependent. A failed lookup is not cached: a
  flaky network must not become a day-long policy.

Found while building it: prefixed declarations (aqua:owner/name,
npm:@scope/pkg) were probed as literal strings, so installed tools reported as
not installed — the same false statement pointed the other way. And adding a
verb tripped kit's own counted claims (mcp-server.ts and MCP_TOOLS_GUIDE.md both
said 71 commands); the invariant worked, the counts are now 72 and the contracts
are regenerated.

Requirement 5 (an upgrade path per installer) is deliberately out: it is a
mutating command with its own consent and read-only-surface questions, and it
belongs with `kit upgrade`, not bolted to a reporting change.

Closes #500

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

kit's test-coverage gate flagged src/commands/tools.ts as a net-new untested
file. The tests it was missing are the ones about the output an operator and a
script actually read: the default lists with a source column and says currency
was NOT checked (silence there would read as checked-and-fine), an unknown
subcommand refuses instead of quietly listing, --json is pure JSON with currency
null until asked, and paths appear only under KIT_TOOLS_PATHS=1.
@github-actions

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

@sandstream
sandstream merged commit 389ef0e into main Aug 20, 2026
19 checks passed
@sandstream
sandstream deleted the feat/500-tool-verification branch August 20, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant